package com.wechat.service.account.starter.customMenu;

import com.alibaba.fastjson.JSONObject;
import com.wechat.service.account.starter.AccessTokenService;
import com.wechat.service.account.starter.BaseWechatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author： ygl
 * @date： 2019/07/10
 * @Description：
 * 自定义菜单查询接口
 */
@Service
public class MenuQueryService extends BaseWechatService {

    /**
     * 自定义菜单查询接口
     * @return
     */
    public JSONObject queryMenu(){
        ResponseEntity<JSONObject> responseEntity = restTemplate.getForEntity(buildQueryMenuUrl(), JSONObject.class);
        return responseEntity.getBody();
    }

    public String buildQueryMenuUrl(){
        return "https://api.weixin.qq.com/cgi-bin/menu/get?access_token="+accessTokenService.getAccessToken();
    }
}
